# Time: 2021/07/04
# Author: ZhaoKugua


import base64
from time import sleep

if __name__ == '__main__':
    print("尝试解密。。。")
    sleep(1.5)
    question_meta = '《01010011010001110110110001001110011000010101011101010110011110010110001001110111==》'
    print('0.原问题文本:\n', question_meta)
    sleep(1.5)
    print('1.首先根据提示，处理中间的8位二进制:')
    text = question_meta[1:-3]
    print(text)
    sleep(1.5)
    print('2.之后按照每八位进行分开放入列表:')
    char_list = []
    for i in range(0, len(text)//8):
        char_list.append(text[0:8])
        text = text[8:]
    print(char_list)
    sleep(1.5)
    print('3.转换为10进制:')
    i = 0
    for char_ascii in char_list:
        char_list[i] = int(char_ascii, 2)
        i += 1
    print(char_list)
    sleep(1.5)
    print('4.转换为ascii对应的字母:')
    i = 0
    for char_ascii_dec in char_list:
        char_list[i] = chr(char_list[i])
        i += 1
    print(char_list)
    sleep(1.5)
    print('5.合并文本，加上之前忽略的结尾的==')
    text = ''
    for char in char_list:
        text = text + char
    text = text + '=='
    print(text)
    sleep(1.5)
    print('6.base64解码:')
    text = base64.b64decode(text)
    print(text)
    sleep(1.5)
    print('或者可以把bytes转换成普通文本:')
    print(text.decode('utf-8'))
